class Myevent {
    constructor(eventObj) {
        this.eventObj = {}; 
    }
    addEvent(eventName, fn) {
        
        if(typeof this.eventObj[eventName] === 'undefined') {
            this.eventObj[eventName] = [];
        }
        this.eventObj[eventName].push(fn);
    }
    trigger(eventName){
        if(typeof this.eventObj[eventName] !== 'undefined') {
            this.eventObj[eventName].forEach(fn => {
                fn();
            })
        }else {
            throw Error('传参错误')
        }
    }
 }
 export default Myevent;